\doxysection{cr\+QUEUE\+\_\+\+SEND\+\_\+\+FROM\+\_\+\+ISR }
\hypertarget{group__cr_q_u_e_u_e___s_e_n_d___f_r_o_m___i_s_r}{}\label{group__cr_q_u_e_u_e___s_e_n_d___f_r_o_m___i_s_r}\index{crQUEUE\_SEND\_FROM\_ISR@{crQUEUE\_SEND\_FROM\_ISR}}
croutine. h 
\begin{DoxyPre}
 crQUEUE\_SEND\_FROM\_ISR(                            QueueHandle\_t pxQueue,                            void *pvItemToQueue,                            BaseType\_t xCoRoutinePreviouslyWoken                       )\end{DoxyPre}


The macro\textquotesingle{}s cr\+QUEUE\+\_\+\+SEND\+\_\+\+FROM\+\_\+\+ISR() and cr\+QUEUE\+\_\+\+RECEIVE\+\_\+\+FROM\+\_\+\+ISR() are the co-\/routine equivalent to the x\+Queue\+Send\+From\+ISR() and x\+Queue\+Receive\+From\+ISR() functions used by tasks.

cr\+QUEUE\+\_\+\+SEND\+\_\+\+FROM\+\_\+\+ISR() and cr\+QUEUE\+\_\+\+RECEIVE\+\_\+\+FROM\+\_\+\+ISR() can only be used to pass data between a co-\/routine and and ISR, whereas x\+Queue\+Send\+From\+ISR() and x\+Queue\+Receive\+From\+ISR() can only be used to pass data between a task and and ISR.

cr\+QUEUE\+\_\+\+SEND\+\_\+\+FROM\+\_\+\+ISR can only be called from an ISR to send data to a queue that is being used from within a co-\/routine.

See the co-\/routine section of the WEB documentation for information on passing data between tasks and co-\/routines and between ISR\textquotesingle{}s and co-\/routines.


\begin{DoxyParams}{Parameters}
{\em x\+Queue} & The handle to the queue on which the item is to be posted.\\
\hline
{\em pv\+Item\+To\+Queue} & A pointer to the item that is to be placed on the queue. The size of the items the queue will hold was defined when the queue was created, so this many bytes will be copied from pv\+Item\+To\+Queue into the queue storage area.\\
\hline
{\em x\+Co\+Routine\+Previously\+Woken} & This is included so an ISR can post onto the same queue multiple times from a single interrupt. The first call should always pass in pd\+FALSE. Subsequent calls should pass in the value returned from the previous call.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pd\+TRUE if a co-\/routine was woken by posting onto the queue. This is used by the ISR to determine if a context switch may be required following the ISR.
\end{DoxyReturn}
Example usage\+: 
\begin{DoxyPre}
// A co-\/routine that blocks on a queue waiting for characters to be received.
static void vReceivingCoRoutine( CoRoutineHandle\_t xHandle, UBaseType\_t uxIndex )
\{
char cRxedChar;
BaseType\_t xResult;

    // All co-\/routines must start with a call to crSTART().
    crSTART( xHandle );

    for( ;; )
    \{
        // Wait for data to become available on the queue.  This assumes the
        // queue xCommsRxQueue has already been created!
        crQUEUE\_RECEIVE( xHandle, xCommsRxQueue, \&uxLEDToFlash, portMAX\_DELAY, \&xResult );

        // Was a character received?
        if( xResult == pdPASS )
        \{
            // Process the character here.
        \}
    \}

    // All co-\/routines must end with a call to crEND().
    crEND();
\}

// An ISR that uses a queue to send characters received on a serial port to
// a co-\/routine.
void vUART\_ISR( void )
\{
char cRxedChar;
BaseType\_t xCRWokenByPost = pdFALSE;

    // We loop around reading characters until there are none left in the UART.
    while( UART\_RX\_REG\_NOT\_EMPTY() )
    \{
        // Obtain the character from the UART.
        cRxedChar = UART\_RX\_REG;

        // Post the character onto a queue.  xCRWokenByPost will be pdFALSE
        // the first time around the loop.  If the post causes a co-\/routine
        // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.
        // In this manner we can ensure that if more than one co-\/routine is
        // blocked on the queue only one is woken by this ISR no matter how
        // many characters are posted to the queue.
        xCRWokenByPost = crQUEUE\_SEND\_FROM\_ISR( xCommsRxQueue, \&cRxedChar, xCRWokenByPost );
    \}
\}\end{DoxyPre}
 